Runge Kutta algorithm for numerical solution of ordinary differential equations

The solution of an ordinary differential equation (ODE) is a function. The function is of a form that it satisfies the relationship between itself and its derivatives as presented by the ODE.

Numericly solving the ODE consists of evaluating the derivative and computing the value of the function at a nearby point. This process is then repeated by evaluating the derivative at the new point and then evaluating the function at the next nearby point. The simplest finite difference algorithm for accomplishing this is called Euler's Method.

, thus

Applied over and over, you get

While Euler's Method is appealing for its simplicity, the algorithm suffers from a low order of accuracy, it is first order. If is halved, the error in the solution is halved. This is not acceptable for real calculations.

The most common algorithm used in practice to solve ODEs is the fourth order Runge-Kutta Method because when is halved, the error is reduced by a factor of or 16. The fourth order Runge-Kutta Method uses a more complicated algorithm for computing the derivative of the unknown function. This leads to a very accurate result in most cases.

where

and with as the selected step size.

While this Runge-Kutta algorithm would be tedious to do on a hand-calculator, it is relatively easy to program this algorithm in many programming languages, including MATLAB. Variants of this algorithm are used in the dsolve(numerical) command in Maple and the ode45 function in MATLAB. In addition to the above steps, these computing tools estimate the error and select the value of to reduce the error. They can be used to approximate to a user specified error level value, such as